import{ut as e}from"./B603vO-13smUKN.js";var t=e(`workspaceIndexStore`),n=`zeed-workspace-index`,r=`workspaces`,i=1;function a(){return new Promise((e,t)=>{let a=indexedDB.open(n,i);a.onupgradeneeded=()=>{let e=a.result;e.objectStoreNames.contains(r)||e.createObjectStore(r,{keyPath:`id`})},a.onsuccess=()=>e(a.result),a.onerror=()=>t(a.error??Error(`open failed`))})}function o(e){return new Promise((t,n)=>{e.oncomplete=()=>t(),e.onabort=()=>n(e.error),e.onerror=()=>n(e.error)})}async function s(e){try{let t=await a();try{return await new Promise((n,i)=>{let a=t.transaction(r,`readonly`).objectStore(r).get(e);a.onsuccess=()=>n(a.result),a.onerror=()=>i(a.error)})}finally{t.close()}}catch(e){t.warn(`getWorkspaceMeta failed`,e);return}}async function c(){try{let e=await a();try{return await new Promise((t,n)=>{let i=e.transaction(r,`readonly`).objectStore(r).getAll();i.onsuccess=()=>t(i.result??[]),i.onerror=()=>n(i.error)})}finally{e.close()}}catch(e){return t.warn(`listWorkspaceMeta failed`,e),[]}}async function l(e,t){let n=await a();try{let i=n.transaction(r,`readwrite`),a=i.objectStore(r),s={...await new Promise((t,n)=>{let r=a.get(e);r.onsuccess=()=>t(r.result),r.onerror=()=>n(r.error)})??{id:e},...t,id:e};return a.put(s),await o(i),s}finally{n.close()}}async function u(e){try{let t=await a();try{let n=t.transaction(r,`readwrite`);n.objectStore(r).delete(e),await o(n)}finally{t.close()}}catch(e){t.warn(`deleteWorkspaceMeta failed`,e)}}function d(e){return e?.localTitle?.trim()||e?.folderName?.trim()||``}export{l as a,d as i,s as n,c as r,u as t};